<!--

    Copyright (C) 2015 The Gravitee team (http://gravitee.io)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<div class="gv-page-container">
  <h1>Administrative roles</h1>
  <div class="gv-page-content" fxLayout="column">
    <p>Administrators can be used to grant access to specific areas of this resource. Depending of the role permissions, administrators can have full access to this resource.</p>
    <p>Administrator users are managed separately from security domain users; administrator accounts represent users that can access to the administration portal.</p>
    <p>The users/groups listed here can either view and/or edit this resource configuration.</p>
    <p *ngIf="isEditable()">Administrators and administrative roles can be assigned <a (click)="openDialog()" style="font-size: 18px; text-decoration: underline; cursor: pointer;">here</a>.</p>

    <ngx-datatable class="material"
                   [columnMode]="'flex'"
                   [headerHeight]="40"
                   [footerHeight]="40"
                   [rowHeight]="50"
                   [rows]='members'
                   [sorts]="[{ prop: 'memberType', dir: 'desc' }]">
      <ngx-datatable-column name="Name" [flexGrow]="4" [cellClass]="'membership-name-cell'">
        <ng-template let-row="row" ngx-datatable-cell-template>
          <div class="membership-header" fxLayout="row">
            <div *ngIf="row.memberType === 'user'" class="user-avatar">
              <app-user-avatar [user]="row" [width]="'40'"></app-user-avatar>
            </div>
            <div *ngIf="row.memberType === 'group'" class="membership-icon">
              <mat-icon>group</mat-icon>
            </div>
            <div class="membership-information" fxLayout="column">
              <h3>{{row.name}}</h3>
            </div>
          </div>
        </ng-template>
      </ngx-datatable-column>
      <ngx-datatable-column name="Type" [flexGrow]="2" prop="memberType">
        <ng-template let-row="row" ngx-datatable-cell-template>
          <p>{{row.memberType}}</p>
        </ng-template>
      </ngx-datatable-column>
      <ngx-datatable-column name="Role" [flexGrow]="2" prop="roleName">
        <ng-template let-row="row" ngx-datatable-cell-template>
          <small><b>{{row.roleName}}</b></small>
        </ng-template>
      </ngx-datatable-column>
    </ngx-datatable>
  </div>
</div>
